package com.bmf.admin.utils;

/**
 * string 工具类
 *
 * @author 
 * @date 2023/02/26
 */
public class StrUtils {
    /**
     * 截取最后一个指定字符
     *
     * @param str     str
     * @param lastStr 最后力量
     * @return {@link String}
     */
    public static String strTrim(String str,String lastStr) {
        if (str.endsWith(lastStr)){
            int lastIndex = str.lastIndexOf(lastStr);
            if (lastIndex != -1) {
                int nextCommaIndex = str.indexOf(lastStr, lastIndex + 1);
                if (nextCommaIndex != -1) {
                    str = str.substring(0, lastIndex) + str.substring(nextCommaIndex);
                } else {
                    str = str.substring(0, lastIndex);
                }
            }
        }
        return str;
    }
}
